package com.cskaoyan.controller;

import com.cskaoyan.bean.vo.*;
import com.cskaoyan.service.ConfigService;
import net.sf.jsqlparser.expression.operators.relational.RegExpMatchOperatorType;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author catsanea
 */
@RestController
public class ConfigController {

    @Autowired
    ConfigService configService;

    //商场GET
    @RequiresPermissions("admin:config:mall:list")
    @RequestMapping(value = "/admin/config/mall", method = RequestMethod.GET)
    public BaseRespVo mall() {
        ConfigMallVO configMallVO = configService.configMall( );
        return BaseRespVo.success(configMallVO);
    }

    //商场POST
    @RequiresPermissions("admin:config:mall:updateConfigs")
    @RequestMapping(value = "/admin/config/mall", method = RequestMethod.POST)
    public BaseRespVo mallPost(@RequestBody ConfigMallVO configMallVO) {
        configService.configMallPost(configMallVO);
        return BaseRespVo.success( );
    }

    //运费GET
    @RequiresPermissions("admin:config:express:list")
    @RequestMapping(value = "/admin/config/express", method = RequestMethod.GET)
    public BaseRespVo express() {
        ConfigExpressVO configExpressVO = configService.configExpress( );
        return BaseRespVo.success(configExpressVO);
    }

    //运费POST
    @RequiresPermissions("admin:config:express:updateConfigs")
    @RequestMapping(value = "/admin/config/express", method = RequestMethod.POST)
    public BaseRespVo expressPost(@RequestBody ConfigExpressVO configExpressVO) {
        configService.configExpressPost(configExpressVO);
        return BaseRespVo.success( );
    }

    //订单GET
    @RequiresPermissions("admin:config:order:list")
    @RequestMapping(value = "/admin/config/order", method = RequestMethod.GET)
    public BaseRespVo order() {
        ConfigOrderVO configOrderVO = configService.configOrder( );
        return BaseRespVo.success(configOrderVO);
    }

    //订单POST
    @RequiresPermissions("admin:config:order:updateConfigs")
    @RequestMapping(value = "/admin/config/order", method = RequestMethod.POST)
    public BaseRespVo orderPost(@RequestBody ConfigOrderVO configOrderVO) {
        configService.configOrderPost(configOrderVO);
        return BaseRespVo.success( );
    }

    //小程序GET
    @RequiresPermissions("admin:config:wx:list")
    @RequestMapping(value = "/admin/config/wx", method = RequestMethod.GET)
    public BaseRespVo wx() {
        ConfigWXVO configWXVO = configService.configWX( );
        System.out.println(configWXVO);
        return BaseRespVo.success(configWXVO);
    }

    //小程序POST
    @RequiresPermissions("admin:config:wx:updateConfigs")
    @RequestMapping(value = "/admin/config/wx", method = RequestMethod.POST)
    public BaseRespVo wxPost(@RequestBody ConfigWXVO configWXVO) {
        configService.configWXPost(configWXVO);
        return BaseRespVo.success( );
    }
}
